//
//  AppDelegate.m
//  HeartMark
//
//  Created by rimi on 2016/11/5.
//  Copyright © 2016年 黄华强. All rights reserved.
//

#import "AppDelegate.h"
#import "HMTabBarViewController.h"
#import <AVOSCloud/AVOSCloud.h>
#import "HMLoginController.h"


@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //设置leancloud代码
    [AVOSCloud setApplicationId:@"3r7uXbsP87hRN1AcbGfqGqHi-gzGzoHsz" clientKey:@"8sFTamX0iK4AzUjSxMOkOoY2"];
    

    //获得系统全局的导航栏
    UINavigationBar* navBar = [UINavigationBar appearance];//appearance 通过这个获得一个全局的单例对象
    //设置标题属性 ----  自身.导航控制器.导航条  setTitle设置标题文本的属性,下面设置的属性有 ：参数1：字体大小(bold是黑体)   参数2:标题前景色
    [navBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],NSForegroundColorAttributeName:[UIColor whiteColor],}];
    navBar.barTintColor = APP_COLOR;
    navBar.tintColor = [UIColor whiteColor];
    
    //加载标签控制器
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    AVUser *currentUser = [AVUser currentUser];
    if (currentUser) {
        HMTabBarViewController *tabBarVC = [[HMTabBarViewController alloc] init];
        self.window.rootViewController = tabBarVC;
    } else {
        HMLoginController *loginVC = [[HMLoginController alloc] init];
        self.window.rootViewController = loginVC;
    }
    
    
    [self.window makeKeyAndVisible];
    
    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    
}


- (void)applicationDidEnterBackground:(UIApplication *)application {

  [[NSNotificationCenter defaultCenter] postNotificationName:@"saveMyNoteNotification" object:nil userInfo:nil];
}


- (void)applicationWillEnterForeground:(UIApplication *)application {

}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    
}


- (void)applicationWillTerminate:(UIApplication *)application {
    
}


@end
